cmake_minimum_required(VERSION 3.16)
project(opencv_test)

set(CMAKE_CXX_STANDARD 14)

add_executable(opencv_test main.cpp)

if (WIN32)
    # 必须先定义opencv安装目录的环境变量
    if (DEFINED ENV{OPENCV_INSTALL_DIR})
        message(STATUS "OpenCV install path:" $ENV{OPENCV_INSTALL_DIR})
    else ()
        message(FATAL_ERROR "OPENCV_INSTALL_DIR env is not defined")
    endif ()

    find_package(OpenCV REQUIRED PATHS $ENV{OPENCV_INSTALL_DIR})

else () # linux
    find_package(OpenCV REQUIRED)
endif ()
#find opencv lib
#set(OpenCV_DIR D:\\opencv440\\opencv\\Mybuild\\install)
find_package(OpenCV REQUIRED)
#message(STATUS ${OpenCV_INCLUDE_DIRS})
message(STATUS ${OpenCV_LIBS})

include_directories(${OpenCV_INCLUDE_DIRS})
target_link_libraries(opencv_test ${OpenCV_LIBS})

add_subdirectory(${PROJECT_SOURCE_DIR}/chapter1)
add_subdirectory(${PROJECT_SOURCE_DIR}/chapter2)
add_subdirectory(${PROJECT_SOURCE_DIR}/chapter3)
add_subdirectory(${PROJECT_SOURCE_DIR}/chapter4)
add_subdirectory(${PROJECT_SOURCE_DIR}/chapter5)
add_subdirectory(${PROJECT_SOURCE_DIR}/chapter6)
add_subdirectory(${PROJECT_SOURCE_DIR}/chapter7)
add_subdirectory(${PROJECT_SOURCE_DIR}/chapter8)
add_subdirectory(${PROJECT_SOURCE_DIR}/chapter9)
add_subdirectory(${PROJECT_SOURCE_DIR}/chapter10)
add_subdirectory(${PROJECT_SOURCE_DIR}/chapter11)
add_subdirectory(${PROJECT_SOURCE_DIR}/chapter12)

#add_subdirectory(${PROJECT_SOURCE_DIR}/yolov4)

